package com.xhtranslate.service.baidu.controller;

import com.xhtranslate.common.vo.ResponseVO;
import com.xhtranslate.service.baidu.service.BaiduOcrService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author liuxuhuang
 * @version 1.0
 * @package com.xhtranslate.service.baidu.controller
 * @date 2022/11/11 16:21:22
 * @description 文字识别控制器
 */
@RestController
@Api(value = "百度OCR请求接口", tags = "百度OCR请求接口")
@RequestMapping(value = "baiduOcr")
@Slf4j
public class BaiduOcrController {
    @Autowired
    private BaiduOcrService baiduOcrService;

    @PostMapping(value = "ocr", consumes = "multipart/form-data")
    @ApiOperation(value = "百度文字识别")
    public ResponseVO baiduOCR(MultipartFile file) throws IOException {
        return ResponseVO.succ(baiduOcrService.ocrImg(file));
    }
}
